﻿function openPicker(id, serverUrl) 
{
    if (!document.getElementById) 
    {
        //No proper JS support. Probably not IE/Firefox.
        return;
    }
    var listTextBox = document.getElementById(id);
    if (listTextBox == null) 
    {
        //Could not find the textbox. Exit.
        return;
    }
    var callback = function(results) {
        if (results == null || results[1] == null) {
            return;
        }
        lastSelectedListSmtPickerId = results[0];
        var listUrl = '';
        if (listUrl.substring(listUrl.length - 1) != '/') listUrl = listUrl + '/';
        if (results[1].charAt(0) == '/') results[1] = results[1].substring(1);
        listUrl = listUrl + results[1];
        if (listUrl.substring(listUrl.length - 1) != '/') listUrl = listUrl + '/';
        if (results[2].charAt(0) == '/') results[2] = results[2].substring(1);
        listUrl = listUrl + results[2];
        listTextBox.value = listUrl;
        document.forms[0].submit();
    };
    LaunchPickerTreeDialog(
        'CbqPickerSelectListTitle',
        'CbqPickerSelectListText',
        'websLists',
        '',
        serverUrl,
        lastSelectedListSmtPickerId,
        '',
        '',
        '/_layouts/images/smt_icon.gif',
        '', 
        callback);
}